package com.bml.architect.sentinel.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.bml.architect.sentinel.exceptions.CommonBlockHandler;
import com.bml.architect.sentinel.exceptions.CommonFallback;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: baiml
 * @Title: DemoController
 * @ProjectName: 中台技术平台
 * @Depart 中台研发部
 * @Description:
 * @date: 2021/4/22 12:49
 */
@RestController
@RequestMapping("/demo")
public class DemoController {


    @RequestMapping("/test")
    public String test() {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "========test()========";
    }

    @RequestMapping("/find/{id}")
    @SentinelResource(value = "findUserInfo",fallbackClass = CommonFallback.class
    ,fallback = "fallback",blockHandlerClass = CommonBlockHandler.class,
    blockHandler = "handleException")
    public String find(@PathVariable("id")Integer id){

        return "find:"+id;
    }
}
